import React, {useCallback, useRef} from 'react';
import XtraModal, {XtraModalMethods} from "@/lib/XtraModal";
import {Button, Space} from "antd";

export default function ModalDemo() {
  //创建组件引用对象
  const modalRef = useRef<XtraModalMethods>(null);
  const onOk = useCallback(() => {
    console.log('ok');
    modalRef.current?.hide();
  }, []);

  return (
    <>
      <Space>
        <Button onClick={() => modalRef.current?.show()}>显示</Button>
        <Button onClick={() => modalRef.current?.hide()}>隐藏</Button>
      </Space>
      <XtraModal ref={modalRef} onOk={onOk} title="模态对话框">
        对话框内容
      </XtraModal>
    </>
  );
};
